<template>
  <div>
    <el-form
      ref="elForm"
      :model="model"
      :rules="rules"
      size="medium"
      label-width="100px"
    >
      <el-form-item label="账号" prop="uName">
        <el-input
          v-model="model.uName"
          placeholder="请输入账号"
          clearable
          :style="{ width: '100%' }"
        ></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="pwds">
        <el-input
          v-model="model.pwds"
          placeholder="请输入密码"
          clearable
          show-password
          :style="{ width: '100%' }"
        >
        </el-input>
      </el-form-item>
      <el-form-item size="large">
        <el-button type="primary" @click="submitForm">提交</el-button>
        <el-button @click="resetForm">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
export default {
  components: {},
  props: [],
  data() {
    return {
      model: {
        uName: undefined,
        pwds: undefined,
      },
      rules: {
        uName: [
          {
            required: true,
            message: "请输入账号",
            trigger: "blur",
          },
        ],
        pwds: [
          {
            required: true,
            message: "请输入密码",
            trigger: "blur",
          },
        ],
      },
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    submitForm() {
      this.$refs["elForm"].validate((valid) => {
        if (valid) {
          this.Login();
        } else {
          return false;
        }
      });
    },
    resetForm() {
      this.$refs["elForm"].resetFields();
    },
    Login() {
      this.$https
        .post(
          "http://localhost:47742/api/Peoples/Login?UName=" +
            this.model.uName +
            "&Pwds=" +
            this.model.pwds
        )
        .then((d) => {
          if (d.data.data > 0) {
            alert("登录成功!");
          } else {
            alert("登录失败!");
          }
        });
    },
  },
};
</script>
<style>
</style>

